<?php
namespace app\admin\controller;
class Goodsevaluate extends Base
{
    //列表
    public function lists(){
        if(is_post()){
            $d = $this->post;
            $map = [];
            if($d['keyword']!=''){ $map[] = ['and','b.username|c.title|e.order_no','like',"%{$d['keyword']}%"]; }
            if($d['grade']!=''){ $map[] = ['and','a.grade','=',$d['grade']]; }
            if($d['min_time']!='') $map[] = ['and','create_time','>=',strtotime($d['min_time'])];
            if($d['max_time']!='') $map[] = ['and','create_time','<=',strtotime($d['max_time'])];

            $model = m('GoodsEvaluate','c');
            $rs = $model->listsinfo($map,'order by a.id desc',$d['page'],$d['limit']);
            if($rs){
                $rule = [
                    'create_time' => 'com_time_format',
                ];
                $rs[0] = com_format($rs[0],$rule);
                suc($rs[0],$rs[1]);
            }else{
                suc([],0);
            }
            $this->fetch();
        }
        return $this->fetch();
    }

    //删除
    public function del(){
        if(is_post()){
            $d = $this->post;
            $info = $this->db->find('goods_evaluate',$d['id']);
            $this->db->delete('goods_evaluate',$d['id']);
            m('Log','xcom')->record($this->userinfo['id'],"删除了商品评价【" . json_encode($info,JSON_UNESCAPED_UNICODE) . "】",'admin_user');
            cookie('js_msg','删除成功');
            cookie('js_function','preload');
            return suc();
        }
    }
}
?>
